home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
130 MIDI Tool Box
/
130 MIDI Tool Box.iso
/
dac12x16
/
stof12.c
< prev
Wrap
C/C++ Source or Header
|
1987-09-23
|
443b
|
20 lines
/* stof12--float to short for 12-bit DAC
* stof12 < infile > outfile
*/
#include <stdio.h>
#include <fcntl.h>
#include <io.h>
#define DAC12 2047 /* 2^12 / 2 - 1 */
main()
{
short x;
float y;
setmode(fileno(stdin), O_BINARY);
setmode(fileno(stdout), O_BINARY);
while (fread((char *)&x, sizeof(short), 1, stdin))
{ y = x / DAC12;
fwrite((char *)&y, sizeof(float), 1, stdout);
}
}